package com.woniuxy.controller;

import com.woniuxy.produce.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @GetMapping("/hello")
    public String hello(){
        return "hello rabbitmq";
    }

    @Autowired
    private SimpleProduce simpleProduce;

    @GetMapping("/simple")
    public void simple(){
        simpleProduce.send();
    }

    @Autowired
    private WorkProduce workProduce;

    @GetMapping("/work")
    public void work(){
        workProduce.send("周6写作业");
    }

    @Autowired
    private FanoutProduce fanoutProduce;

    @GetMapping("/fanout")
    public void fanout(){
        fanoutProduce.send("一天内70多起事故，小米SU7自动泊车出现故障，官方承认是小米系统bug");
    }

    @Autowired
    private DirectProduce directProduce;

    @GetMapping("/direct/{key}")
    public void direct(@PathVariable("key") String key){
        directProduce.send(key,"今天下雨记得带伞");
    }

    @Autowired
    private TopicProduce topicProduce;

    @GetMapping("/topic/{key}")
    public void topic(@PathVariable("key") String key){
        topicProduce.send(key,"今天晚上吃火锅");
    }

    @Autowired
    private DelayProduce delayProduce;

    @GetMapping("/delay")
    private void delay(){
        delayProduce.send("delay","延迟消息",5000);
    }
}
